-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove root parameter override in watch mode #925
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these changes are too disruptive for any existing scenarios.
I think most people don't pass root
as parameter and that should still work as everybody expects it.
src/fsdocs-tool/BuildCommand.fs
Outdated
| _ -> None | ||
|
||
r, userParameters | ||
let userRoot = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will clash later on with
FSharp.Formatting/src/fsdocs-tool/ProjectCracker.fs
Lines 611 to 614 in 2efb355
let root = | |
let projectUrl = projectInfoForDocs.PackageProjectUrl |> Option.map ensureTrailingSlash | |
defaultArg userRoot (defaultArg projectUrl ("/" + collectionName) |> ensureTrailingSlash) |
Just following the instructions in the readme (dotnet build
and src\fsdocs-tool\bin\Debug\net6.0\fsdocs.exe watch
) will launch everything pointing to https://fsprojects.github.io/FSharp.Formatting
and not localhost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is heading in the right direction but I do have some remarks.
[<Option("contenthost", Required = false, HelpText = "URI root to inject in static content.")>] | ||
member val contenthost = "" with get, set | ||
|
||
override x.static_content_host_option = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip with -p Verify
! That's helpful.
Though the output is quite verbose with results from the other projects. It also seems to create diffs in the tests/
directory for me. Not sure if that's intentional.
src/fsdocs-tool/BuildCommand.fs
Outdated
@@ -2115,3 +2119,13 @@ type WatchCommand() = | |||
|
|||
[<Option("port", Required = false, Default = 8901, HelpText = "Port to serve content for http://localhost serving.")>] | |||
member val port = 8901 with get, set | |||
|
|||
[<Option("contenthost", Required = false, HelpText = "URI root to inject in static content.")>] | |||
member val contenthost = "" with get, set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add documentation for this new setting.
I'm not quite convinced about the flag name and help text.
I also have some slight concerns that invalid input won't be displayed nicely to the end-users.
If you value for this is blah
, Suave might trip over it.
It is also not quite clear if http://
or https://
needs to be included in this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say:
Please add documentation for this new setting.
Do you mean just in the HelpText
? Or is there somewhere else that I should be adding a more verbose description?
And good point about the invalid input. I added a call to System.Uri
in the override
to get its built-in parse errors. Do you think that is helpful enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HelpText is a great start and I would like you to also add an entry in https://fsprojects.github.io/FSharp.Formatting/commandline.html (see https://github.com/fsprojects/FSharp.Formatting/blob/main/docs/commandline.md).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it! And yes I will look into friendly-ifying the URI error.
Running
but leads to This also makes me wonder if we should go for a breaking change and introduce a Thoughts @kMutagene @nhirschey? |
Yes, I noticed that those parameters could become out of sync. But isn't it possible that both E.g.
In this case, the static content should all replace |
Hmm, yes, that is a plausible scenario. However, it does make me wonder if we should not bet more on making relative paths a thing? |
Yes, that would also work, I think. I am not very familiar with Suave, but I have used the rust and python abstractions for "just start an HTTP file server in this directory" before. I assume Suave has something similar or it's easy enough to create. |
I don't think this would be very Suave related. The bigger issues is that |
It seems complicated to document or explain contentroot, root, and port simultaneously. It's a bit of an edge case that anybody would use these together, and maybe a suboptimal edge case is ok, but still a bit of a hack. If I understand the problem correctly, a single --root and then relative paths seems the cleanest way forward if it's possible. More work to get it right, but perhaps a better long-term foundation. I don't know why it's absolute rather than relative paths now. |
Agreed with everything that has been said so far, but moving PRs to the 'More work to get it right, but perhaps a better long-term foundation' solution tends to stall PRs such as this - see my still-open PR of shame on this repo. @tymokvo would you be up for escalating the scope of this PR that much? Otherwise i'd suggest publishing a 'good enough' solution only in preview versions, and another maintainer/contributor picking up from there in future PRs. |
I would be happy to contribute a better long-term solution! But I was hoping to be able to get this merge-ready before the deadline I have at work now. So, I wouldn't be able to resume this for a couple weeks. As long as you all are ok with this PR going stale for that amount of time, then I can revisit. And, just so that I'm clear, the direction would be:
...correct? My main concern would be the risk of breaking changes since the scope would be so broad and would affect any project that depends on |
Hi @tymokvo, thanks for the offer. We have a call with the maintainers tomorrow, I'll bring it up over there. |
@@ -1406,10 +1404,13 @@ type CoreBuildOptions(watch) = | |||
// Adjust the user substitutions for 'watch' mode root | |||
let userRoot, userParameters = | |||
if watch then | |||
let userRoot = sprintf "http://localhost:%d/" this.port_option | |||
let userRoot = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
let userRoot =
match userParametersDict.TryGetValue(ParamKeys.root) with
| true, root -> root
| false, _ -> sprintf "http://localhost:%d/" this.port_option
work for you here?
I believe it can be an easy way to make
fsdocs watch --parameters root "/"
work and would be the least disruptive for now.
We don't feel good enough about the new setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test and let you know! Thanks for talking it through!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, thanks for your patience!
Summary
watch
flag for injecting a URL root into static site content for non-localhost
browsersif watch
to replace root override with the passed URL rootwindow.location
Description
This adds the ability to serve the generated documentation site to browsers not running on
localhost
. For example, when working in a remote development environment like GitHub Codespaces or anngrok
endpoint.